/*
 * IniciaSplash.java
 *
 * Created on 3 de julio de 2007, 11:51
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package SplashWindow;
import gr.zeus.ui.JSplash;
import gr.zeus.util.GUIUtils;
import java.awt.Color;
import java.awt.Font;
import java.util.Random;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import java.net.URL;

public class IniciaSplash {
    
    public IniciaSplash( String n ) {
        this.carga_mensajes();
        this.contMsg = 1;
        this.contPorc = 20;
        URL dir_url;
        try{            
            dir_url = IniciaSplash.class.getResource("/Recursos/Splash.png");
            splash = new JSplash( 
            dir_url, // the image
            true, // do we want a progress bar?
            true, // do we want messages displayed during loading?
            false, // do we want percent displayed instead of messages?
            "Bienvenido... " + n, // do we want to display a text message at the 
                               // bottom-right corner e.g. version number
            new Font("Tahoma", Font.BOLD, 13), // do we want another font?
            new Color( 0, 128, 0 ) ); // do we need another color other than black?
        }catch( Exception er ){
            er.printStackTrace();
        }        
        splash.splashOn();        
    }
    
    private void carga_mensajes(){
        String[] msg = {
            null,
            "Inicializando", "Cargando Librerias", "Construyendo GUI",
            "Conectando a la Base Datos", "Inicializando GUI", 
            null                 
        };
        msgCarga = msg;
    }
    
    public void cierra(){
        splash.splashOff();
        splash.dispose();
    }
    
    public void avanza(){
        splash.setProgress( this.contPorc, msgCarga[ this.contMsg ]);
        this.contMsg++;
        this.contPorc += 20;
        try{
            Thread.sleep( 500 );
        }catch( Exception er ){
            
        }
        
    }
    
    public static void main( String[] args ){
        new IniciaSplash( "Francisco" );
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    
    
    
    private JSplash splash;
    private String[] msgCarga;
    private int contMsg; 
    private int contPorc;
    
}
